function saveData(figur,input,name)
% Part of our homemade Save function for our GUI. This function saves the 
% user-specified input and the corresponding figure to an extensionless
% savefile to avoid users corrupting the save file.

%% Saving data in temp folder
%Figure
hgsave(figur,'.\SaveFiles\smiles.fig')

%Input
fName = '.\SaveFiles\input.txt'; % Saves input inside a text file
fid = fopen(fName,'w');
if fid~=-1
    fprintf(fid,'%s\r\n',input);
    fclose(fid);
end

%% Zipping files
oldDir = cd('.\SaveFiles'); %changes dir to SaveFiles dir

zipfile = strcat(name{1},'.zip'); % creates the name of the zipfile by
% combining the user input with '.zip'
zip(zipfile,{'smiles.fig','input.txt'}); %Zips a savefile
file = textscan(zipfile,'%s','delimiter','.');
movefile(zipfile,char(file{1}(1))); %removes the .zip extension

delete('smiles.fig','input.txt') %deletes temp files
cd(oldDir) %Changes dir back to main dir.

end

